<?php 
	class account extends CI_Controller
	{
		public function __construct()
		{
			parent::__construct();
		}
		
		public function index()
		{
		    //$accountId=1;
		    $username=$this->session->userdata('username');
            //Kiểm tra account đã đăng nhập hay chưa
		    if(empty($username)||is_null($username))
            {
                //header("location:/account/login");
                redirect('admincp/account/login');
            }
            else 
            {
                $this->load->view('admincp/layout/header');
                $this->load->view('admincp/layout/page_content');
                $this->load->view('admincp/layout/_layout');
                $this->load->view('/admincp/account/index');
            }
            
		}
		
        public function Login()
        {
            $this->load->view('/admincp/account/login_form');
        }
        
		public function DoLogin()
		{
			$this->load->model("/admincp/account_model");
			//$query = $this->db->query($sql,array($this->input->post('username'),$this->input->post('password')));
			//echo "Username:{$this->input->post('username')},Password:{$this->input->post('password')}";
			if($this->account_model->check_login($this->input->post('username'),$this->input->post('password'))==true)
			{
				$data = array(
					"username" => $this->input->post("username"),
					"is_login" => true,
				);
				$this->session->set_userdata($data);
				redirect("/admincp/account/index");
			}
			else
			{
				
                redirect("/admincp/account/login");
			}
		}
		
	}
?>